import axios from '@/libs/api.request'

const prefix = '/web/trainCenter'

const TrainCenterApi = {
  pageResult(trainCenter) {
    return axios.request({
      url: prefix + '/pageResult',
      data: trainCenter,
      method: 'post'
    })
  },
  saveOrUpdate(trainCenter) {
    return axios.request({
      url: prefix + "/saveOrUpdate",
      method: 'post',
      data: trainCenter
    })
  },
  saveOrUpdateMail(trainCenter) {
    return axios.request({
      url: prefix + "/mail/saveOrUpdate",
      method: 'post',
      data: trainCenter
    })
  },
  delete(id) {
    return axios.request({
      url: prefix + '/' + id,
      method: 'delete'
    })
  },
  userTrainCenterScope() {
    return axios.request({
      url: prefix + '/userTrainCenterScope',
      method: 'get'
    })
  },
  get(id) {
    return axios.request({
      url: prefix + '/' + id,
      method: 'get'
    })
  },
  queryTrainCenterCoachs(id) {
    return axios.request({
      url: prefix + '/coachs/' + id,
      method: 'get'
    })
  },
  queryTrainCenterTrainers(id) {
    return axios.request({
      url: prefix + '/trainer/' + id,
      method: 'get'
    })
  },
  validAdminPhone(phone) {
    return axios.request({
      url: prefix + '/validAdmin/' + phone,
      method: 'get'
    })
  },
  validAdminMail(mail) {
    return axios.request({
      url: prefix + '/validAdmin/mail/mail?mail=' + encodeURIComponent(mail),
      method: 'get'
    })
  },
  updateTrainCenterAdmin(trainCenter, data) {
    return axios.request({
      url: prefix + '/admin/' + trainCenter,
      data: data,
      method: 'post'
    })
  },
  getUserTrainCenterNames() {
    return axios.request({
      url: prefix + '/names',
      method: 'get'
    })
  }
}

export default TrainCenterApi
